import request from '../model/http';

export const baseUrl = "https://api.sunofbeach.net/shop";

const SUCCESS_CODE = 10000;

export default {
    SUCCESS_CODE,

    getCategories() {
        return request.requestGet(baseUrl + "/discovery/categories");
    },

    getCategoriesContent(materialId, page) {
        return request.requestGet(baseUrl + "/discovery/" + materialId + "/" + page);
    },

    /**
     * 用代理的方法解决跨域问题
     *
     * 规则由 nuxt.config.js 36行定义
     *
     * @param materialId
     * @param page
     * @returns {Promise | Promise<unknown>}
     */
    getCategoriesContentByProxy(materialId, page) {
        return request.requestGet("/union/discovery/" + materialId + "/" + page);
    },

    getRecommendCategories() {
        return request.requestGet(baseUrl + "/recommend/categories");
    },

    getRecommendContent(categoryID) {
        return request.requestGet(baseUrl + "/recommend/" + categoryID);
    },
    getRecommendContentByProxy(categoryID) {
        return request.requestGet("/union/recommend/" + categoryID);
    },

    getOnSellContent(page) {
        return request.requestGet(baseUrl + "/onSell/" + page);
    }
}
